Imports System.Xml
Imports DotNetPM.Business.Questionnaire.UserControls
Imports DotNetPM.Business.Questionnaire.Taker

Partial Class Modules_Questionnaires_Controls_ansLoader
    Inherits System.Web.UI.UserControl

    Public Overridable Property Answer() As String
        Get
            Return CType(uc, IAnswerUC).Answer
        End Get
        Set(ByVal value As String)
            CType(uc, IAnswerUC).Answer = value
        End Set
    End Property

    Public Property Config() As String
        Get
            Return hfConfig.Value
        End Get
        Set(ByVal value As String)
            hfConfig.Value = value
        End Set
    End Property

    Public Property QuestionID() As String
        Get
            Return hfId.Value
        End Get
        Set(ByVal value As String)
            hfId.Value = value
        End Set
    End Property

    Public Property SortID() As String
        Get
            Return hfSortId.Value
        End Get
        Set(ByVal value As String)
            hfSortId.Value = value
        End Set
    End Property

#Region "Private Area"

    Private uc As UserControl

    Private Sub LoadMyControl()
        If uc Is Nothing Then
            If Not String.IsNullOrEmpty(Config) Then
                Dim type As String = Config.Substring(0, 1)
                Dim myXML As XmlDocument = ControlXDS.GetXmlDocument
                Dim myNode As XmlNode = myXML.SelectSingleNode("/controlList/control[@id=" & type & "]")
                uc = LoadControl(ResolveUrl("ans" & myNode.Attributes("control").Value))
                uc.ID = "ansUC"
                CType(uc, IAnswerUC).Config = SortID & "||" & QuestionID & "||" & Config
                phLoader.Controls.Add(uc)
            End If
        End If
    End Sub

#End Region

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        LoadMyControl()
    End Sub


    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        LoadMyControl()
    End Sub
End Class
